package org.ticketing.model;

import java.sql.Date;
import java.sql.Time;

import javax.persistence.*;

/*
 * Il test funziona ma ho dovuto modificare event e far diventare movietheatre una stringa, 
 * di modo che possa essere mappato nel database.
 * */


public class PersistenceTest2 {
	  
	public static void main(String[] args) {
	  System.out.println("Unit test JPA ");  
	  
	  EntityManagerFactory factory = Persistence.createEntityManagerFactory("DB");
	  EntityManager manager = factory.createEntityManager();
	  
	  MovieTheatre corallo = new MovieTheatre("Corallo", 180);
	  
//	  manager.getTransaction().begin();
//	  manager.persist(corallo);
//	  manager.getTransaction().commit();

	  Event starw = new Event(3, "Star Wars", "Science-fiction", "description 01", Time.valueOf("17:00:00"), 
			  Date.valueOf("2014-01-04"), 8.50d, corallo.getTheatreName());
	  
	  manager.getTransaction().begin();
	  manager.persist(starw);
	  manager.getTransaction().commit();
	}
}
